//
//  AvatarView.m
//  HotMumTest
//
//  Created by Yang Min on 13-5-19.
//  Copyright (c) 2013年 Yang Min. All rights reserved.
//

#import "AvatarView.h"
#import "ConstantHeader.h"
#import "Tool.h"

@implementation AvatarView

- (id)initWithFrame:(CGRect)frame bgImg:(UIImage *)bgImg
{
    self = [self initWithFrame:frame bgImg:bgImg highBgImg:nil];
    return self;
}

- (id)initWithFrame:(CGRect)frame bgImg:(UIImage *)bgImg highBgImg:(UIImage *)highBgimg{
    self = [self initWithFrame:frame];
    if (self) {
        self.backgroundColor=[UIColor clearColor];
        self.bgImgView=[[UIImageView alloc]initWithFrame:self.bounds];
        _bgImgView.image=bgImg;
        _bgImgView.highlightedImage=highBgimg;
        [self insertSubview:_bgImgView belowSubview:_avatarBtn];
    }
    return self;
}

-(id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.clipsToBounds=YES;
        self.avatarBtn=[UIButton buttonWithType:UIButtonTypeCustom];
        FillButton(_avatarBtn);
        _avatarBtn.frame=self.bounds;
        [self addSubview:_avatarBtn];
        //CALayer *layer = _avatarBtn.layer;
        //layer.cornerRadius = 0.5;
        //layer.masksToBounds = YES;
    }
    return self;
}
-(void)awakeFromNib{
    [super awakeFromNib];
    self.backgroundColor=[UIColor clearColor];

}
-(void)dealloc{
    [_avatarBtn cancelCurrentImageLoad];

}

-(void)cancelNetRequest{
    [_avatarBtn cancelCurrentImageLoad];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end
